home *** CD-ROM | disk | FTP | other *** search
/ PC Answers 1995 May / PC Answers CD-ROM 7 (Future Publishing) (May 1995).iso / vbits / code / mee / vbdao / visdata / tableobj.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1994-10-06  |  24.8 KB  |  844 lines

  1. VERSION 2.00
  2. Begin Form fTableObj 
  3.    BackColor       =   &H00C0C0C0&
  4.    ClientHeight    =   3495
  5.    ClientLeft      =   1335
  6.    ClientTop       =   2625
  7.    ClientWidth     =   5655
  8.    Height          =   3900
  9.    Icon            =   0
  10.    Left            =   1275
  11.    LinkTopic       =   "Form1"
  12.    MDIChild        =   -1  'True
  13.    ScaleHeight     =   3480
  14.    ScaleMode       =   0  'User
  15.    ScaleWidth      =   5675.316
  16.    Tag             =   "Dynaset"
  17.    Top             =   2280
  18.    Width           =   5775
  19.    Begin PictureBox FieldHeader 
  20.       BackColor       =   &H00C0C0C0&
  21.       BorderStyle     =   0  'None
  22.       Height          =   240
  23.       Left            =   0
  24.       ScaleHeight     =   240
  25.       ScaleMode       =   0  'User
  26.       ScaleWidth      =   5028
  27.       TabIndex        =   22
  28.       Top             =   720
  29.       Width           =   5025
  30.       Begin Label FieldValueLabel 
  31.          BackColor       =   &H00C0C0C0&
  32.          Caption         =   " Value  (F4=Zoom) "
  33.          Height          =   255
  34.          Left            =   1680
  35.          TabIndex        =   24
  36.          Top             =   0
  37.          Width           =   3165
  38.       End
  39.       Begin Label FieldHdrLabel 
  40.          BackColor       =   &H00C0C0C0&
  41.          Caption         =   "Field Name:"
  42.          Height          =   252
  43.          Left            =   120
  44.          TabIndex        =   23
  45.          Top             =   0
  46.          Width           =   1212
  47.       End
  48.    End
  49.    Begin PictureBox ViewButtons 
  50.       Align           =   1  'Align Top
  51.       BackColor       =   &H00C0C0C0&
  52.       BorderStyle     =   0  'None
  53.       Height          =   735
  54.       Left            =   0
  55.       ScaleHeight     =   735
  56.       ScaleMode       =   0  'User
  57.       ScaleWidth      =   5658.375
  58.       TabIndex        =   1
  59.       TabStop         =   0   'False
  60.       Top             =   0
  61.       Width           =   5655
  62.       Begin ComboBox cIndexes 
  63.          BackColor       =   &H00FFFFFF&
  64.          Height          =   300
  65.          Left            =   720
  66.          Style           =   2  'Dropdown List
  67.          TabIndex        =   9
  68.          Tag             =   "OLS"
  69.          Top             =   360
  70.          Width           =   4335
  71.       End
  72.       Begin CommandButton SeekButton 
  73.          Caption         =   "&Seek"
  74.          Height          =   330
  75.          Left            =   2160
  76.          TabIndex        =   5
  77.          Top             =   0
  78.          Width           =   750
  79.       End
  80.       Begin CommandButton FilterButton 
  81.          Caption         =   "F&ilter"
  82.          Height          =   330
  83.          Left            =   2880
  84.          TabIndex        =   6
  85.          Top             =   0
  86.          Width           =   750
  87.       End
  88.       Begin CommandButton CloseButton 
  89.          Cancel          =   -1  'True
  90.          Caption         =   "&Close"
  91.          Height          =   330
  92.          Left            =   4305
  93.          TabIndex        =   8
  94.          TabStop         =   0   'False
  95.          Top             =   0
  96.          Width           =   750
  97.       End
  98.       Begin CommandButton PropButton 
  99.          Caption         =   "&Prop"
  100.          Height          =   330
  101.          Left            =   3600
  102.          TabIndex        =   7
  103.          Top             =   0
  104.          Width           =   750
  105.       End
  106.       Begin CommandButton DelButton 
  107.          Caption         =   "&Del"
  108.          Height          =   330
  109.          Left            =   1440
  110.          TabIndex        =   4
  111.          Top             =   0
  112.          Width           =   750
  113.       End
  114.       Begin CommandButton EditButton 
  115.          Caption         =   "&Edit"
  116.          Height          =   330
  117.          Left            =   720
  118.          TabIndex        =   3
  119.          Top             =   0
  120.          Width           =   750
  121.       End
  122.       Begin CommandButton AddButton 
  123.          Caption         =   "&Add"
  124.          Height          =   330
  125.          Left            =   0
  126.          TabIndex        =   2
  127.          Top             =   0
  128.          Width           =   750
  129.       End
  130.       Begin Label IndexLabel 
  131.          BackColor       =   &H00C0C0C0&
  132.          Caption         =   "Index:"
  133.          Height          =   255
  134.          Left            =   120
  135.          TabIndex        =   25
  136.          Top             =   400
  137.          Width           =   615
  138.       End
  139.    End
  140.    Begin PictureBox ChangeButtons 
  141.       BackColor       =   &H00C0C0C0&
  142.       BorderStyle     =   0  'None
  143.       Height          =   690
  144.       Left            =   0
  145.       ScaleHeight     =   690
  146.       ScaleMode       =   0  'User
  147.       ScaleWidth      =   5658.375
  148.       TabIndex        =   14
  149.       TabStop         =   0   'False
  150.       Top             =   0
  151.       Visible         =   0   'False
  152.       Width           =   5655
  153.       Begin CommandButton UpdateButton 
  154.          Caption         =   "&Update"
  155.          Height          =   372
  156.          Left            =   960
  157.          TabIndex        =   16
  158.          Top             =   48
  159.          Width           =   1212
  160.       End
  161.       Begin CommandButton CancelButton 
  162.          Caption         =   "&Cancel"
  163.          Height          =   372
  164.          Left            =   2640
  165.          TabIndex        =   15
  166.          Top             =   48
  167.          Width           =   1212
  168.       End
  169.    End
  170.    Begin PictureBox StatBox 
  171.       Align           =   2  'Align Bottom
  172.       BackColor       =   &H00C0C0C0&
  173.       BorderStyle     =   0  'None
  174.       Height          =   281
  175.       Left            =   0
  176.       ScaleHeight     =   298.153
  177.       ScaleMode       =   0  'User
  178.       ScaleWidth      =   5665.188
  179.       TabIndex        =   20
  180.       TabStop         =   0   'False
  181.       Top             =   3210
  182.       Width           =   5655
  183.       Begin CommandButton NextButton 
  184.          Caption         =   ">"
  185.          Height          =   287
  186.          Left            =   4200
  187.          TabIndex        =   12
  188.          Top             =   0
  189.          Width           =   375
  190.       End
  191.       Begin CommandButton LastButton 
  192.          Caption         =   ">|"
  193.          Height          =   287
  194.          Left            =   4575
  195.          TabIndex        =   13
  196.          Top             =   0
  197.          Width           =   375
  198.       End
  199.       Begin CommandButton FirstButton 
  200.          Caption         =   "|<"
  201.          Height          =   287
  202.          Left            =   0
  203.          TabIndex        =   10
  204.          Top             =   0
  205.          Width           =   375
  206.       End
  207.       Begin CommandButton PrevButton 
  208.          Caption         =   "<"
  209.          Height          =   287
  210.          Left            =   375
  211.          TabIndex        =   11
  212.          Top             =   0
  213.          Width           =   375
  214.       End
  215.       Begin Label cStatusBar 
  216.          BackColor       =   &H00FFFFFF&
  217.          BorderStyle     =   1  'Fixed Single
  218.          Height          =   285
  219.          Left            =   735
  220.          TabIndex        =   21
  221.          Top             =   0
  222.          Width           =   3360
  223.       End
  224.    End
  225.    Begin VScrollBar cScrollBar 
  226.       Height          =   2616
  227.       LargeChange     =   3000
  228.       Left            =   5040
  229.       SmallChange     =   300
  230.       TabIndex        =   19
  231.       Top             =   960
  232.       Visible         =   0   'False
  233.       Width           =   252
  234.    End
  235.    Begin PictureBox cFields 
  236.       BackColor       =   &H00C0C0C0&
  237.       BorderStyle     =   0  'None
  238.       Height          =   375
  239.       Left            =   120
  240.       ScaleHeight     =   372
  241.       ScaleMode       =   0  'User
  242.       ScaleWidth      =   4812
  243.       TabIndex        =   17
  244.       TabStop         =   0   'False
  245.       Top             =   960
  246.       Width           =   4815
  247.       Begin TextBox cFieldData 
  248.          BackColor       =   &H00FFFFFF&
  249.          DataSource      =   "Data1"
  250.          ForeColor       =   &H00000000&
  251.          Height          =   288
  252.          Index           =   0
  253.          Left            =   1560
  254.          TabIndex        =   0
  255.          Top             =   0
  256.          Visible         =   0   'False
  257.          Width           =   3252
  258.       End
  259.       Begin Label cFieldName 
  260.          BackColor       =   &H00C0C0C0&
  261.          ForeColor       =   &H00000000&
  262.          Height          =   252
  263.          Index           =   0
  264.          Left            =   0
  265.          TabIndex        =   18
  266.          Top             =   60
  267.          Visible         =   0   'False
  268.          Width           =   1572
  269.       End
  270.    End
  271. Option Explicit
  272. 'form variables
  273. Dim FTBL As Table             'current form's table
  274. Dim FTblName As String        'form dynaset table name
  275. Dim FBM As String             'form bookmark
  276. Dim FNotFound As Integer      'used by find function
  277. Dim FAtTop As Integer         'top flag
  278. Dim FEditFlag As Integer      'edit mode
  279. Dim FAddNewFlag As Integer    'add mode
  280. Dim FFldDataChanged As Integer
  281. Dim FSeekForm As New fSeek    'seek form instance
  282. Dim FCurrRec As Long          'record counter
  283. Dim FNumbRows As Long         'total rows in Table
  284. Sub AddButton_Click ()
  285.   On Error GoTo AddErr
  286.   'set the mode
  287.   FTBL.AddNew
  288.   cStatusBar = "Add record"
  289.   FAddNewFlag = True
  290.   If FTBL.RecordCount > 0 Then
  291.     FBM = FTBL.Bookmark
  292.   Else
  293.     FBM = NULL_STR
  294.   End If
  295.   ChangeButtons.Visible = True
  296.   ViewButtons.Visible = False
  297.   NextButton.Enabled = False
  298.   FirstButton.Enabled = False
  299.   LastButton.Enabled = False
  300.   PrevButton.Enabled = False
  301.   ClearDataFields
  302.   cFieldData(0).SetFocus
  303.   GoTo AddEnd
  304. AddErr:
  305.   ShowError
  306.   Resume AddEnd
  307. AddEnd:
  308. End Sub
  309. Sub CancelButton_Click ()
  310.    On Error Resume Next
  311.    ChangeButtons.Visible = False
  312.    ViewButtons.Visible = True
  313.    NextButton.Enabled = True
  314.    FirstButton.Enabled = True
  315.    LastButton.Enabled = True
  316.    PrevButton.Enabled = True
  317.    FEditFlag = False
  318.    FAddNewFlag = False
  319.    If Len(FBM) > 0 Then FTBL.Bookmark = FBM
  320.    DisplayCurrentRecord
  321. End Sub
  322. Sub cFieldData_Change (Index As Integer)
  323.   'just set the flag if data is changed
  324.   'it gets reset to false when a new record is displayed
  325.   FFldDataChanged = True
  326. End Sub
  327. Sub cFieldData_KeyDown (Index As Integer, KeyCode As Integer, Shift As Integer)
  328.   If KeyCode = &H73 Then   'F4
  329.     cFieldName_DblClick Index
  330.   ElseIf KeyCode = 34 And cScrollBar.Visible = True Then
  331.     'pagedown with > 10 fields
  332.     cScrollBar = cScrollBar - 3000
  333.   ElseIf KeyCode = 33 And cScrollBar.Visible = True Then
  334.     'pageup with > 10 fields
  335.     cScrollBar = cScrollBar + 3000
  336.   End If
  337. End Sub
  338. Sub cFieldData_KeyPress (Index As Integer, KeyAscii As Integer)
  339.   'only allow return when in edit of add mode
  340.   If FEditFlag = True Or FAddNewFlag = True Then
  341.     If KeyAscii = 13 Then
  342.       KeyAscii = 0
  343.       SendKeys "{Tab}"
  344.     End If
  345.   'throw away the keystrokes if not in add or edit mode
  346.   ElseIf FEditFlag = False And FAddNewFlag = False Then
  347.     KeyAscii = 0
  348.   End If
  349. End Sub
  350. Sub cFieldData_LostFocus (Index As Integer)
  351.   On Error GoTo FldDataErr
  352.   If FFldDataChanged = True Then
  353.     'store the data in the field
  354.     FTBL(Index) = cFieldData(Index)
  355.   End If
  356.   GoTo FldDataEnd
  357. FldDataErr:
  358.   ShowError
  359.   Resume FldDataEnd
  360. FldDataEnd:
  361.   'reset for valid or error condition
  362.   FFldDataChanged = False
  363. End Sub
  364. Sub cFieldName_DblClick (Index As Integer)
  365.   On Error GoTo ZoomErr
  366.   If FTBL(Index).Type = FT_STRING Or FTBL(Index).Type = FT_MEMO Then
  367.      If FTBL(Index).FieldSize() < GETCHUNK_CUTOFF Then
  368.        gstZoomData = cFieldData(Index)
  369.      Else
  370.        'add the rest of the field data with getchunk
  371.        MsgBar "Getting Memo Field Data", True
  372.        SetHourglass Me
  373.        gstZoomData = cFieldData(Index) + StripNonAscii(FTBL(Index).GetChunk(GETCHUNK_CUTOFF, MAX_MEMO_SIZE))
  374.        ResetMouse Me
  375.        MsgBar NULL_STR, False
  376.      End If
  377.      fZoom.caption = Mid(cFieldName(Index), 1, Len(cFieldName(Index)) - 1)
  378.      fZoom.Top = Top + 1200
  379.      fZoom.Left = Left + 250
  380.      If FAddNewFlag Or FEditFlag Then
  381.        fZoom.SaveButton.Visible = True
  382.        fZoom.CloseButton.Visible = True
  383.      Else
  384.        fZoom.CloseZoomButton.Visible = True
  385.      End If
  386.      If FTBL(Index).Type <> FT_MEMO Then
  387.        fZoom.cData = gstZoomData
  388.        fZoom.Height = 1125
  389.      Else
  390.        fZoom.cMemo = gstZoomData
  391.        fZoom.cMemo.Visible = True
  392.        fZoom.cData.Visible = False
  393.        fZoom.Height = 2205
  394.      End If
  395.      fZoom.Show MODAL
  396.      If (FAddNewFlag Or FEditFlag) And gstZoomData <> "__CANCELLED__" Then
  397.        If FTBL(Index).Type = FT_STRING And Len(gstZoomData) > FTBL(Index).Size Then
  398.          Beep
  399.          MsgBox "Field Length Exceeded, Data Truncated!", 48
  400.          cFieldData(Index) = Mid(gstZoomData, 1, FTBL(Index).Size)
  401.        Else
  402.          cFieldData(Index) = gstZoomData
  403.        End If
  404.        FTBL(Index) = cFieldData(Index)
  405.        FFldDataChanged = False
  406.      End If
  407.   End If
  408.   GoTo ZoomEnd
  409. ZoomErr:
  410.   ShowError
  411.   Resume ZoomEnd
  412. ZoomEnd:
  413. End Sub
  414. Sub cIndexes_Click ()
  415.   On Error GoTo IndErr
  416.   If FTBL Is Nothing Then Exit Sub
  417.   If FTBL.Index = Mid(cIndexes, 1, InStr(1, cIndexes, ":") - 1) Then Exit Sub
  418.   FTBL.Index = Mid(cIndexes, 1, InStr(1, cIndexes, ":") - 1)
  419.   FCurrRec = 1
  420.   DisplayCurrentRecord
  421.   FAtTop = True
  422.   GoTo IndEnd
  423. IndErr:
  424.   ShowError
  425.   Resume IndEnd
  426. IndEnd:
  427. End Sub
  428. Sub ClearDataFields ()
  429.   Dim i As Integer
  430.   'clear out the fields on the main form
  431.   For i = 0 To FTBL.Fields.Count - 1
  432.     cFieldData(i) = NULL_STR
  433.   Next
  434. End Sub
  435. Sub CloseButton_Click ()
  436.   Unload Me
  437. End Sub
  438. Sub cScrollBar_Change ()
  439.   Dim t As Integer
  440.   t = cScrollBar
  441.   If (t - 960) Mod 300 = 0 Then
  442.     cFields.Top = t
  443.   Else
  444.     cFields.Top = ((t - 960) \ 300) * 300 + 960
  445.   End If
  446. End Sub
  447. Sub DelButton_Click ()
  448.   On Error GoTo DelRecErr
  449.   If MsgBox("Delete Current Record?", MSGBOX_TYPE) = YES Then
  450.     FTBL.Delete
  451.     If gfTransPending Then gfDBChanged = True
  452.     If FTBL.EOF = False Then
  453.       FTBL.MoveNext
  454.     End If
  455.     FNumbRows = FNumbRows - 1
  456.     DisplayCurrentRecord
  457.   End If
  458.   GoTo DelRecEnd
  459. DelRecErr:
  460.   ShowError
  461.   Resume DelRecEnd
  462. DelRecEnd:
  463. End Sub
  464. Sub DisplayCurrentRecord ()
  465.    Dim i As Integer
  466.    Dim cst As String    'current status bar
  467.    Dim currstr As String
  468.    On Error GoTo DCRErr
  469.    SetHourglass Me
  470.    If FCurrRec = -1 And FTBL.RecordCount = 0 Then
  471.      currstr = "?"
  472.    Else
  473.      currstr = CStr(FCurrRec)
  474.    End If
  475.    cst = "Record "
  476.    'check BOF/EOF flag so we know if we
  477.    'are sitting on a valid record
  478.    If FAddNewFlag = True Then
  479.      cst = cst & currstr & " of " & FNumbRows
  480.    Else
  481.      If FTBL.BOF = True Then
  482.        FCurrRec = 0
  483.        cst = cst & "(BOF) of " & FNumbRows
  484.        ClearDataFields
  485.      ElseIf FTBL.EOF = True Then
  486.        FCurrRec = FNumbRows + 1
  487.        cst = cst & "(EOF) of " & FNumbRows
  488.        ClearDataFields
  489.      Else
  490.        cst = cst & currstr & " of " & FNumbRows
  491.        'place the data in the form fields
  492.        For i = 0 To FTBL.Fields.Count - 1
  493.          If FTBL(i).Type = FT_MEMO Then
  494.            If FTBL(i).FieldSize() < GETCHUNK_CUTOFF Then
  495.              cFieldData(i) = StripNonAscii(vFieldVal(FTBL(i)))
  496.            Else
  497.              cFieldData(i) = StripNonAscii(vFieldVal(FTBL(i).GetChunk(0, GETCHUNK_CUTOFF)))
  498.            End If
  499.          ElseIf FTBL(i).Type = FT_STRING Then
  500.            cFieldData(i) = StripNonAscii(vFieldVal(FTBL(i)))
  501.          Else
  502.            cFieldData(i) = vFieldVal(FTBL(i))
  503.          End If
  504.        Next
  505.      End If
  506.    End If
  507.    If FTBL.Updatable = False Then cst = cst & "  [Not Updatable]"
  508.    cStatusBar = cst
  509.    'set the flag
  510.    FFldDataChanged = False
  511.    GoTo DCREnd
  512. DCRErr:
  513.   ShowError
  514.   Resume DCREnd
  515. DCREnd:
  516.    ResetMouse Me
  517. End Sub
  518. Sub EditButton_Click ()
  519.    On Error GoTo EditErr
  520.    FTBL.Edit
  521.    cStatusBar = "Edit record"
  522.    FEditFlag = True
  523.    cFieldData(0).SetFocus
  524.    FBM = FTBL.Bookmark
  525.    ChangeButtons.Visible = True
  526.    ViewButtons.Visible = False
  527.    NextButton.Enabled = False
  528.    FirstButton.Enabled = False
  529.    LastButton.Enabled = False
  530.    PrevButton.Enabled = False
  531.    GoTo EditEnd
  532. EditErr:
  533.   ShowError
  534.   Resume EditEnd
  535. EditEnd:
  536. End Sub
  537. Sub FilterButton_Click ()
  538.   On Error GoTo FilterErr
  539.   Dim FilterStr As String
  540.   Dim f As New fDynaset
  541.   FilterStr = InputBox("Enter Filter Expression:")
  542.   If Len(FilterStr) = 0 Then Exit Sub
  543.   gstTableDynaFilter = "select * from " & AddBrackets(FTblName) & " where " & FilterStr
  544.   f.Show                           'open dynaset form w/ filtered table
  545.   gstTableDynaFilter = NULL_STR
  546.   GoTo FilterEnd
  547. FilterErr:
  548.   ShowError
  549.   Resume FilterEnd
  550. FilterEnd:
  551. End Sub
  552. Sub FirstButton_Click ()
  553.    Dim ds As String
  554.    On Error GoTo GoFirstError
  555.    FTBL.MoveFirst
  556.    FCurrRec = 1
  557.    DisplayCurrentRecord
  558.    FAtTop = True
  559.    GoTo GoFirstEnd
  560. GoFirstError:
  561.    ShowError
  562.    Resume GoFirstEnd
  563. GoFirstEnd:
  564.    ResetMouse Me
  565.    MsgBar NULL_STR, False
  566. End Sub
  567. Sub Form_KeyDown (KeyCode As Integer, Shift As Integer)
  568.   If FEditFlag = True Or FAddNewFlag = True Then Exit Sub
  569.   Select Case KeyCode
  570.     Case 35                'end
  571.       Call LastButton_Click
  572.     Case 36                'home
  573.       Call FirstButton_Click
  574.     Case 38                'up arrow
  575.       If Shift = 2 Then
  576.         Call FirstButton_Click
  577.       Else
  578.         Call PrevButton_Click
  579.       End If
  580.     Case 40                'down arrow
  581.       If Shift = 2 Then
  582.         Call LastButton_Click
  583.       Else
  584.         Call NextButton_Click
  585.       End If
  586.   End Select
  587. End Sub
  588. Sub Form_Load ()
  589.    Dim ft As Integer
  590.    Dim i As Integer
  591.    Dim tbl As TableDef
  592.    Dim istr As String
  593.    On Error GoTo TableErr
  594.    SetHourglass Me
  595.    MsgBar "Opening Table", True
  596.    FTblName = fTables.cTableList
  597.    Set tbl = gCurrentDB.TableDefs(FTblName)
  598.    For i = 0 To tbl.Indexes.Count - 1
  599.      istr = tbl.Indexes(i).Name
  600.      istr = istr & ":" & tbl.Indexes(i).Fields
  601.      If tbl.Indexes(i).Unique = True Then
  602.        istr = istr & ":Unique"
  603.      Else
  604.        istr = istr & ":Non-Unique"
  605.      End If
  606.      If tbl.Indexes(i).Primary = True Then
  607.        istr = istr & ":Primary"
  608.      End If
  609.      cIndexes.AddItem istr
  610.    Next
  611.    Set FTBL = gCurrentDB.OpenTable(FTblName)
  612.    'show the first record
  613.    FNumbRows = GetNumbRecsTbl(FTBL)          'query numb of recs
  614.    'load the controls on the Table form
  615.    cFieldName(0).Visible = True
  616.    cFieldData(0).Visible = True
  617.    ft = FTBL(0).Type
  618.    cFieldData(0).Width = GetFieldWidth(ft)
  619.    cFieldData(0).TabIndex = 0
  620.    If ft = FT_STRING Then cFieldData(0).MaxLength = FTBL(0).Size
  621.    For i = 1 To FTBL.Fields.Count - 1
  622.      cFields.Height = cFields.Height + 300
  623.      Load cFieldName(i)
  624.      cFieldName(i).Top = cFieldName(i - 1).Top + 300
  625.      cFieldName(i).Visible = True
  626.      Load cFieldData(i)
  627.      cFieldData(i).Top = cFieldData(i - 1).Top + 300
  628.      cFieldData(i).Visible = True
  629.      ft = FTBL.Fields(i).Type
  630.      cFieldData(i).Width = GetFieldWidth(ft)
  631.      cFieldData(i).TabIndex = i
  632.      If ft = FT_STRING Then cFieldData(i).MaxLength = FTBL(i).Size
  633.    Next
  634.    'resize main window
  635.    If i <= 10 Then
  636.      Height = ((i + 1) * 300) + 1600
  637.    Else
  638.      Height = 4668
  639.      Width = Width + 260
  640.      cScrollBar.Visible = True
  641.      cScrollBar.Min = 900
  642.      cScrollBar.Max = 900 - (i * 300&) + 3000
  643.    End If
  644.    'display the field names
  645.    For i = 0 To FTBL.Fields.Count - 1
  646.      cFieldName(i) = UCase(FTBL(i).Name) & ":"
  647.    Next
  648.    FCurrRec = 1
  649.    If cIndexes.ListCount > 0 Then
  650.      cIndexes.ListIndex = 0
  651.    End If
  652.    DisplayCurrentRecord      'display field values
  653.    FAtTop = True
  654.    caption = "Table: " & FTblName
  655.    Width = 5805
  656.    Left = 1000
  657.    Top = 1000
  658.    GoTo OkayEnd
  659. TableErr:
  660.    ShowError
  661.    ResetMouse Me
  662.    Unload Me
  663.    MsgBar NULL_STR, False
  664.    Exit Sub
  665.    Resume OkayEnd
  666. OkayEnd:
  667.    ResetMouse Me
  668.    MsgBar NULL_STR, False
  669. End Sub
  670. Sub Form_Paint ()
  671.   Outlines Me
  672. End Sub
  673. Sub Form_Resize ()
  674.   On Error Resume Next
  675.   Dim h As Integer, i As Integer
  676.   Dim totw As Integer
  677.   If WindowState <> 1 Then   'not minimized
  678.     MsgBar "Resizing Form", True
  679.     'make sure the form is lined up on a field
  680.     h = Height
  681.     If (h - 1660) Mod 300 <> 0 Then
  682.       Height = ((h - 1660) \ 300) * 300 + 1660
  683.     End If
  684.     'resize the status bar
  685.     StatBox.Top = Height - 650
  686.     'resize the scrollbar
  687.     cScrollBar.Height = StatBox.Top - (ViewButtons.Top - FieldHeader.Height) - 1200
  688.     cScrollBar.Left = Width - 360
  689.     If FTBL.Fields.Count > 10 Then
  690.       cFields.Width = Width - 260
  691.       totw = cScrollBar.Left - 20
  692.     Else
  693.       cFields.Width = Width - 20
  694.       totw = Width - 50
  695.     End If
  696.     FieldHeader.Width = Width - 20
  697.     'widen the fields if possible
  698.     For i = 0 To FTBL.Fields.Count - 1
  699.       cFieldName(i).Width = .3 * totw
  700.       cFieldData(i).Left = cFieldName(i).Width + 20
  701.       If FTBL(i).Type = FT_STRING Or FTBL(i).Type = FT_MEMO Then
  702.         cFieldData(i).Width = .7 * totw - 250
  703.       End If
  704.     Next
  705.     FieldValueLabel.Left = cFieldData(0).Left
  706.     cStatusBar.Width = Width - 1600
  707.     NextButton.Left = cStatusBar.Width + 745
  708.     LastButton.Left = NextButton.Left + 370
  709.   End If
  710.   MsgBar NULL_STR, False
  711. End Sub
  712. Sub Form_Unload (Cancel As Integer)
  713.   On Error Resume Next
  714.   Unload FSeekForm   'get rid of attached seek form
  715.   FTBL.Close          'close the form Table
  716.   MsgBar NULL_STR, False
  717. End Sub
  718. Sub LastButton_Click ()
  719.    On Error GoTo GoLastError
  720.    FTBL.MoveLast
  721.    'show the current record
  722.    FCurrRec = FNumbRows
  723.    DisplayCurrentRecord
  724.    GoTo GoLastEnd
  725. GoLastError:
  726.    ShowError
  727.    Resume GoLastEnd
  728. GoLastEnd:
  729. End Sub
  730. Sub NextButton_Click ()
  731.    On Error GoTo GoNextError
  732.    FTBL.MoveNext
  733.    'show the current record
  734.    If FCurrRec <> -1 Then
  735.      FCurrRec = FCurrRec + 1   'bump the record counter
  736.    End If
  737.    DisplayCurrentRecord
  738.    FAtTop = False
  739.    GoTo GoNextEnd
  740. GoNextError:
  741.    ShowError
  742.    Resume GoNextEnd
  743. GoNextEnd:
  744. End Sub
  745. Sub PrevButton_Click ()
  746.    On Error GoTo GoPrevError
  747.    FTBL.MovePrevious
  748.    'show the current record
  749.    If FCurrRec <> -1 Then
  750.      FCurrRec = FCurrRec - 1   'bump the record counter back
  751.    End If
  752.    DisplayCurrentRecord
  753.    FAtTop = False
  754.    GoTo GoPrevEnd
  755. GoPrevError:
  756.    ShowError
  757.    Resume GoPrevEnd
  758. GoPrevEnd:
  759. End Sub
  760. Sub PropButton_Click ()
  761.    Dim f As New fDataBox
  762.    On Error GoTo DynPropErr
  763.    Set gCurrentTbl = FTBL
  764.    f.caption = "Table Properties"
  765.    f.Tag = "TBL"
  766.    f.cData.AddItem "Name = " & FTBL.Name
  767.    f.cData.AddItem "BOF Flag = " & stTrueFalse((FTBL.BOF))
  768.    f.cData.AddItem "BookMark = " & FTBL.Bookmark
  769.    f.cData.AddItem "BookMarkable Flag = " & stTrueFalse((FTBL.Bookmarkable))
  770.    f.cData.AddItem "Date Created = " & FTBL.DateCreated
  771.    f.cData.AddItem "EOF Flag = " & stTrueFalse((FTBL.EOF))
  772.    f.cData.AddItem "Index = " & FTBL.Index
  773.    f.cData.AddItem "Last Modified = " & FTBL.LastModified
  774.    f.cData.AddItem "Last Updated = " & FTBL.LastUpdated
  775.    f.cData.AddItem "Lock Edits Flag = " & stTrueFalse((FTBL.LockEdits))
  776.    f.cData.AddItem "No Match Flag = " & stTrueFalse((FTBL.NoMatch))
  777.    f.cData.AddItem "Transactions Flag = " & stTrueFalse((FTBL.Transactions))
  778.    f.cData.AddItem "RecordCount = " & FTBL.RecordCount
  779.    f.cData.AddItem "Updatable Flag = " & stTrueFalse((FTBL.Updatable))
  780.    f.Show MODAL
  781.   GoTo DynPropEnd
  782. DynPropErr:
  783.   f.cData.AddItem Error$
  784.   Resume Next
  785. DynPropEnd:
  786. End Sub
  787. Sub SeekButton_Click ()
  788.   On Error GoTo SeekErr
  789.   Dim bm As String
  790.   If FTBL.RecordCount = 0 Then Exit Sub
  791. SeekStart:
  792.   MsgBar "Enter Seek Parameters", False
  793.   fSeek.Show MODAL
  794.   If Len(gstSeekValue) = 0 Then GoTo SeekEnd
  795.   bm = FTBL.Bookmark
  796.   SetHourglass Me
  797.   FTBL.Seek gstSeekOperator, gstSeekValue
  798.   ResetMouse Me
  799.   'return to old record if no match was found
  800.   If FTBL.NoMatch And Len(bm) > 0 Then
  801.     Beep
  802.     MsgBox "Record Not Found", 48
  803.     FTBL.Bookmark = bm
  804.     GoTo SeekStart
  805.   Else
  806.     If FCurrRec <> -1 Then
  807.       MsgBox "Current Record Number cannot be retained after Seek!"
  808.     End If
  809.     FCurrRec = -1  'set to -1 because it is no longer valid
  810.   End If
  811.   DisplayCurrentRecord
  812.   GoTo SeekEnd
  813. SeekErr:
  814.   ResetMouse Me
  815.   MsgBox Error$
  816.   Resume SeekEnd
  817. SeekEnd:
  818.   MsgBar NULL_STR, False
  819. End Sub
  820. Sub UpdateButton_Click ()
  821.   On Error GoTo UpdateErr
  822.   FTBL.Update
  823.   If gfTransPending Then gfDBChanged = True
  824.   If FAddNewFlag = True Then
  825.     FNumbRows = FNumbRows + 1
  826.     FCurrRec = FNumbRows
  827.     FTBL.MoveLast               'move to the new record
  828.   End If
  829.   FEditFlag = False
  830.   FAddNewFlag = False
  831.   ChangeButtons.Visible = False
  832.   ViewButtons.Visible = True
  833.   NextButton.Enabled = True
  834.   FirstButton.Enabled = True
  835.   LastButton.Enabled = True
  836.   PrevButton.Enabled = True
  837.   DisplayCurrentRecord
  838.   GoTo UpdateEnd
  839. UpdateErr:
  840.   ShowError
  841.   Resume UpdateEnd
  842. UpdateEnd:
  843. End Sub
  844.